/* eslint-disable @typescript-eslint/no-explicit-any */
/*
 *  Copyright 2021 Collate
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

 /**
 * 标准信息
 */
export interface Standardinfo {
    /**
     * 是否有效.
     */
    avaliable?: boolean;
    /**
     * 归属单位
     */
    belonginUnit?: string;
    /**
     * 定义
     */
    certDefinition: string;
    /**
     * Change that lead to this version of the entity.
     */
    changeDescription?: ChangeDescription;
    /**
     * dataAssetDir the Database service belongs to.
     */
    dataAssetDir?: EntityReference;
    /**
     * 数据类型
     */
    dataType?: DataTypeClass;
    /**
     * When `true` indicates the entity has been soft deleted.
     */
    deleted?: boolean;
    /**
     * Description of the classification.
     */
    description: string;
    /**
     * System classifications can't be deleted. Use this flag to disable them.
     */
    disabled?: boolean;
    /**
     * Display Name that identifies this entity.
     */
    displayName?: string;
    /**
     * Domain the Database service belongs to.
     */
    domain?: EntityReference;
    /**
     * 英文名称
     */
    enName?: string;
    /**
     * 表示词
     */
    expressWord?: string;
    /**
     * 特性词
     */
    featuresWord?: string;
    /**
     * FullyQualifiedName same as `name`.
     */
    fullyQualifiedName?: string;
    /**
     * Link to the resource corresponding to the classification.
     */
    href?: string;
    /**
     * Unique identifier of this entity instance.
     */
    id?: string;
    /**
     * 语言环境
     */
    languageEnv?: string;
    /**
     * 最大出现次数
     */
    maximum?: number;
    /**
     * 计量单位
     */
    measurementUnit?: string;
    /**
     * Tags under this classification are mutually exclusive. When mutually exclusive is `true`
     * the tags from this classification are used to **classify** an entity. An entity can only
     * be in one class - example, it can only be either `tier1` or `tier2` and not both. When
     * mutually exclusive is `false`, the tags from this classification are used to
     * **categorize** an entity. An entity have multiple tags simultaneously - example a
     * customer can be `newCustomer` and `atRisk` simultaneously.
     */
    mutuallyExclusive?: boolean;
    name:               string;
    /**
     * 拼音缩写
     */
    pinyinAbbr?: string;
    /**
     * 中文全拼
     */
    pinyinAll?: string;
    provider?:  ProviderType;
    /**
     * 关系
     */
    relationship?: string;
    /**
     * 是否必填
     */
    required?: boolean;
    /**
     * 数据编码
     */
    standardCode: string;
    /**
     * 所属的标准类型
     */
    standardType?: StandardTypeClass;
    /**
     * 所属的标准类型Name
     */
    standardTypefullyQualifiedEntityName?: string;
    /**
     * 所属的标准类型id
     */
    standardTypeId: string;
    style?:         Style;
    /**
     * 同义词
     */
    synonyms?: string;
    /**
     * 对象类词
     */
    targetObjectWord?: string;
    /**
     * Total number of children tag terms under this classification. This includes all the
     * children in the hierarchy.
     */
    termCount?: number;
    /**
     * Last update time corresponding to the new version of the entity in Unix epoch time
     * milliseconds.
     */
    updatedAt?: number;
    /**
     * User who made the update.
     */
    updatedBy?: string;
    /**
     * Count of how many times the tags from this classification are used.
     */
    usageCount?: number;
    /**
     * 值域
     */
    valueDomain?: ValueDomain;
    /**
     * Metadata version of the entity.
     */
    version?: number;
    /**
     * 中文名称
     */
    zhName?: string;
}

/**
 * Change that lead to this version of the entity.
 *
 * Description of the change.
 */
export interface ChangeDescription {
    /**
     * Names of fields added during the version changes.
     */
    fieldsAdded?: FieldChange[];
    /**
     * Fields deleted during the version changes with old value before deleted.
     */
    fieldsDeleted?: FieldChange[];
    /**
     * Fields modified during the version changes with old and new values.
     */
    fieldsUpdated?: FieldChange[];
    /**
     * When a change did not result in change, this could be same as the current version.
     */
    previousVersion?: number;
}

export interface FieldChange {
    /**
     * Name of the entity field that changed.
     */
    name?: string;
    /**
     * New value of the field. Note that this is a JSON string and use the corresponding field
     * type to deserialize it.
     */
    newValue?: any;
    /**
     * Previous value of the field. Note that this is a JSON string and use the corresponding
     * field type to deserialize it.
     */
    oldValue?: any;
}

/**
 * dataAssetDir the Database service belongs to.
 *
 * This schema defines the EntityReference type used for referencing an entity.
 * EntityReference is used for capturing relationships from one entity to another. For
 * example, a table has an attribute called database of type EntityReference that captures
 * the relationship of a table `belongs to a` database.
 *
 * Domain the Database service belongs to.
 */
export interface EntityReference {
    /**
     * If true the entity referred to has been soft-deleted.
     */
    deleted?: boolean;
    /**
     * Optional description of entity.
     */
    description?: string;
    /**
     * Display Name that identifies this entity.
     */
    displayName?: string;
    /**
     * Fully qualified name of the entity instance. For entities such as tables, databases
     * fullyQualifiedName is returned in this field. For entities that don't have name hierarchy
     * such as `user` and `team` this will be same as the `name` field.
     */
    fullyQualifiedName?: string;
    /**
     * Link to the entity resource.
     */
    href?: string;
    /**
     * Unique identifier that identifies an entity instance.
     */
    id: string;
    /**
     * If true the relationship indicated by this entity reference is inherited from the parent
     * entity.
     */
    inherited?: boolean;
    /**
     * Name of the entity instance.
     */
    name?: string;
    /**
     * Entity type/class name - Examples: `database`, `table`, `metrics`, `databaseService`,
     * `dashboardService`...
     */
    type: string;
}

/**
 * 数据类型
 *
 * 数据标准数据类型.
 *
 * 数据条件范围.
 */
export interface DataTypeClass {
    /**
     * condition1.
     */
    condition1?: string;
    /**
     * condition2.
     */
    condition2?: string;
    /**
     * opType of the data.
     */
    opType?: OpType;
    /**
     * opTypeShow of the data.["大于", "小于", "等于", "介于"]
     */
    opTypeShow?: string;
    /**
     * Type of the data.
     */
    type?: DataTypeType;
    /**
     * typeShow of the data.["字符串", "数字", "字符串或数字"]
     */
    typeShow?: string;
}

/**
 * opType of the data.
 */
export enum OpType {
    BT = "bt",
    Eq = "eq",
    Gt = "gt",
    Lt = "lt",
}

/**
 * Type of the data.
 */
export enum DataTypeType {
    All = "all",
    Int = "int",
    String = "string",
}

/**
 * Type of provider of an entity. Some entities are provided by the `system`. Some are
 * entities created and provided by the `user`. Typically `system` provide entities can't be
 * deleted and can only be disabled.
 */
export enum ProviderType {
    System = "system",
    User = "user",
}

/**
 * 所属的标准类型
 *
 * 数据标准数据类型.
 */
export interface StandardTypeClass {
    /**
     * condition1.
     */
    condition1?: string;
    /**
     * condition2.
     */
    condition2?: string;
    /**
     * opType of the data.
     */
    opType?: OpType;
    /**
     * opTypeShow of the data.["大于", "小于", "等于", "介于"]
     */
    opTypeShow?: string;
    /**
     * Type of the data.
     */
    type?: DataTypeType;
    /**
     * typeShow of the data.["字符串", "数字", "字符串或数字"]
     */
    typeShow?: string;
}

/**
 * UI Style is used to associate a color code and/or icon to entity to customize the look of
 * that entity in UI.
 */
export interface Style {
    /**
     * Hex Color Code to mark an entity such as GlossaryTerm, Tag, Domain or Data Product.
     */
    color?: string;
    /**
     * An icon to associate with GlossaryTerm, Tag, Domain or Data Product.
     */
    iconURL?: string;
}

/**
 * 值域
 *
 * 数据标准值域.
 */
export interface ValueDomain {
    /**
     * 编码表.
     */
    code?: string;
    /**
     * 数据条件范围.
     */
    dataCondition?: DataTypeClass;
    /**
     * 指定数据类型.
     */
    dataType?: DataTypeEnum;
    /**
     * 指定数据类型显示.["字符串", "数字"]
     */
    dataTypeShow?: string;
    /**
     * 其他标准.
     */
    otherStandard?: string;
    /**
     * 正则表达式.
     */
    regularExpression?: string;
    /**
     * Type of the data.
     */
    type: ValueDomainType;
    /**
     * typeShow of the data.["编码表", "数字条件范围", "指定数据类型","正则表达式", "其他标准"]
     */
    typeShow?: string;
}

/**
 * 指定数据类型.
 */
export enum DataTypeEnum {
    Number = "number",
    String = "string",
}

/**
 * Type of the data.
 */
export enum ValueDomainType {
    Code = "code",
    DataCondition = "dataCondition",
    DataType = "dataType",
    OtherStandard = "otherStandard",
    RegularExpression = "regularExpression",
}
